<?php
    //pr($messages); die();
    echo $this->Html->div('message-top-header', __('<span class="sender-header-title">Sender</span><span class="message-header-title">Message</span>', true));
    $li = '';

    foreach($messages as $m){
       $senderName = $this->Html->tag('span', $this->Html->link($m['User']['username'], '/'.$m['User']['username']), array('class' => 'sender-name'));
       $senderThumb = $this->Html->tag('span', $this->Html->image($m['avatar'], array('url' => '/'.$m['User']['username'])) . $senderName, array('class' => 'author-thumb'));
       
       $messageDetail = $this->Html->tag('p', $m['Message']['message'], array('class' => 'message-detail'));

       //
       $linkDelet = $this->Html->link(__('Delete', true), array('action' => 'delete', $m['Message']['id']), null, __('Are you sure you want to delete this message', true));

       $actions = $this->Html->tag('li', $this->Html->tag('span', sprintf( __('<span class="ui-icon ui-icon-arrowreturnthick-1-w"></span> %s', true), $this->Html->link(__('Reply', true), array( 'action' => 'reply', $m['Message']['id'], $m['Message']['sender_id'])))));
       $actions .= $this->Html->tag('li', $this->Html->tag('span', sprintf(__('<span class="ui-icon ui-icon-close"></span> %s', true), $linkDelet)));

       $actions = $this->Html->div('actions-wrap', $this->Html->tag('ul', $actions, array('class' => 'actions clearfix')));
       $messageDiv = $this->Html->div('message-wrap', $messageDetail.$actions);
       
       $li .= $this->Html->tag('li', $senderThumb . $messageDiv, array('class' => 'notice clearfix'));

    }
    echo $this->Html->tag('ul', $li, array('id' => 'section_notice'));
?>